//package com.example.demo.config;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity;
//import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
//import org.springframework.security.config.web.server.ServerHttpSecurity;
//import org.springframework.security.core.userdetails.MapReactiveUserDetailsService;
//import org.springframework.security.core.userdetails.ReactiveUserDetailsService;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.security.web.server.SecurityWebFilterChain;
//
//import static org.springframework.security.config.Customizer.withDefaults;
//
//@Configuration
//@EnableReactiveMethodSecurity(useAuthorizationManager=true)
//@EnableWebFluxSecurity
//public class SecurityConfig {
//
//    @Bean
//    public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
//        http.authorizeExchange(authorize -> authorize
//                        .pathMatchers("/all").permitAll()
//                        .pathMatchers("/users/login").permitAll()
//                        //.anyExchange().authenticated()
//                ).httpBasic(withDefaults()).formLogin(withDefaults()).csrf(csrf -> csrf.disable()).cors(cors->cors.disable());
//
//        return http.build();
//    }
//
//
//    @Bean
//    public ReactiveUserDetailsService userDetailsService(){
//        UserDetails user = User.builder()
//                .username("admin")
//                .password("$2a$10$sW1bnLew3ke00vASzpXoKuipUlVrsXVfOt1g.zewY.Lq2pT/9V1YG")
//                .roles("admin").authorities("admin","hr")
//                .build();
//        return new MapReactiveUserDetailsService(user);
//    }
//
//    @Bean
//    public PasswordEncoder passwordEncoder(){
//        return new BCryptPasswordEncoder();
//    }
//
//    public static void main(String[] args) {
//        System.out.println(new BCryptPasswordEncoder().encode("123"));
//    }
//}
